package com.mall.b2c.controller;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mall.b2c.service.VouchersService;
import com.mall.b2c.util.JsonDataGridHelper;
import com.mall.common.bean.Pager;
import com.mall.common.bean.SearchFilter;
import com.mall.common.controller.BaseController;
import com.mall.common.web.Servlets;

/**
 * 付款凭证单
 * @author lzx
 *
 */
@Controller
@RequestMapping("/admin/b2c/vouchers")
public class VouchersController extends BaseController{
	
	@Resource private VouchersService vouchersService;

	/**
	 * 列表页面
	 * 
	 * @return
	 */
	@RequestMapping(value="/list", method=RequestMethod.GET)
	public String list() {
    	return "/admin/b2c/vouchers/list";
	}

	@RequestMapping(value="/queryData", method=RequestMethod.POST)
	@ResponseBody
	public Pager queryData(Pager pager, HttpServletRequest request){
		Map<String, Object> filterParams = Servlets.getParametersStartingWith(request);
		List<SearchFilter> filters = SearchFilter.parse(filterParams);
		pager = vouchersService.findPage(pager, filters);
		return JsonDataGridHelper.createJSONData(pager);
	}
}
